 
<header id="header" class="mui-bar mui-bar-black mui-bar-nav">
    <a class="mui-icon mui-icon-left-nav mui-pull-left"  href="{:url('user/index')}"></a>
    <h1 class="mui-title">财务申报</h1>
</header>
<form id='applyform'  method="POST" action="">
<br><br><br>
<div class="mui-content mui-content-my addProject schedule">
    <div class="mui-input-row mui-radio my-radio">
        <label>申报类型</label>
        <span style="margin-right: 1em">收入</span>
        <input type='hidden' id='apply_type' name='apply_type' value='2'>
        <div id='mui-switch' class="mui-switch mui-switch-blue mui-active">
            <div class="mui-switch-handle"></div>
        </div>
         <span>支出</span>
    </div>
    <div class="mui-input-row mui-radio my-radio my-radio1">
        <label>申报单位</label>
        <input type='hidden' id='flag' name='flag' value='2'>
        <span style="margin-right: 1em">工地</span>
        <div id='gd-mui-switch' class="mui-switch mui-switch-blue mui-active">
            <div class="mui-switch-handle"></div>
        </div>
        <span>公司</span>
    </div>
    <div class="mui-input-row" id="showUserPicker">
        <label>工地/公司</label>
        <input id="site_id" name='site_id' type='hidden'>
        <input id="userResult" name='site_name' readonly type="text" placeholder="请选择工地"  class="my-icon-arrowright">
    </div>
    <div class="mui-input-row" id="showUserPicker1">
        <label>所属类别</label>
        <input id="userResult1" name='parent_code' readonly type="text" placeholder="请选择所属类别"  class="my-icon-arrowright">
    </div>
    <div class="mui-input-row">
        <label>费用名称</label>
        <input type="text"  name='code' name='code' placeholder="请输入费用名称">
    </div>
    <div class="mui-input-row input-row-txt">
        <label>金额</label>
        <input name='amount' type="text"><label>元</label>
    </div>
    <div class="mui-input-row">
        <label>备注</label>
        <textarea id="textarea" name='bz' rows="5" placeholder=""></textarea>
    </div>
    <div class="mui-input-row my-icon-arrowright" style="border-bottom: none">
        <label style="width: 50%">附件（选填）</label>
    </div>
    <div class="selected-user-img">
        <div id="preview"></div>
        <div href="javascript:;" class="file">
            <input type="file" name="" multiple id="file_upload">
        </div>
    </div>
</div>
<div class="mui-content-padded">
    <button style="background: linear-gradient(-90deg, #3383FD, #78C2FF);border: none" type="botton" onclick='checkstatus();' class="mui-btn mui-btn-primary mui-btn-block">申报</button>
</div>
</form>
<script src="__CDN__/style/js/jquery-1.11.3.js"></script>
<script src="__CDN__/style/js/mui.poppicker.js"></script>
<script src="__CDN__/style/js/mui.picker.min.js"></script>
<script src="__CDN__/style/js/city.data.js"></script>
<script>
function checkstatus(){ 
    if($('#mui-switch').hasClass("mui-active")){
        $('#apply_type').val(2);
    }else{
        $('#apply_type').val(1);
    }
    if($('#gd-mui-switch').hasClass("mui-active")){
        $('#flag').val(2);
    }else{
        $('#flag').val(1);
    }
}



    (function($,doc) {

        $(function () {
            var userPicker = new $.PopPicker();
            userPicker.setData({$siteList});
            var showUserPickerButton = doc.getElementById('showUserPicker');
            var userResult = doc.getElementById('userResult');
            showUserPickerButton.addEventListener('tap', function(event) {
                userPicker.show(function(items) {
                    var rul= JSON.stringify(items[0].text);
                    doc.getElementById('site_id').value = JSON.stringify(items[0].value);
                    var rula=rul.replace('"','').replace('"','');
                    userResult.value = rula;
                    //返回 false 可以阻止选择框的关闭
                    //return false;
                });
            }, false);
        });
        $(function () {
            var userPicker = new $.PopPicker();
            userPicker.setData([{
                value: '1',
                text: '支出'
            }, {
                value: '0',
                text: '收入'
            }]);
            var showUserPickerButton = doc.getElementById('showUserPicker1');
            var userResult = doc.getElementById('userResult1');
            showUserPickerButton.addEventListener('tap', function(event) {
                userPicker.show(function(items) {
                    var rul= JSON.stringify(items[0].text);
                    var rula=rul.replace('"','').replace('"','');
                    userResult.value = rula;
                    //返回 false 可以阻止选择框的关闭
                    //return false;
                });
            }, false);
        });
    })(mui,document);
    $(function() {
        $("#file_upload").change(function() {
            var $file = $(this);
            var fileObj = $file[0];
            var windowURL = window.URL || window.webkitURL;
            var dataURL;
            var $img = $("#preview");

            if(fileObj && fileObj.files && fileObj.files[0]){
                dataURL = windowURL.createObjectURL(fileObj.files[0]);
                $img.css({width:'6em',height:'6em'}).html('<img src="'+dataURL+'">');
                //console.log(fileObj.files.length);
            }else{
                dataURL = $file.val();
                var imgObj = document.getElementById("preview");
                imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;
            }
        });
    });
</script>
 